=head1 BASE INFORMATION

=head2  Filename

Root.pm

=head2  Path

/lib/Controller/

=head2  Notes

=head2  ToDo's

=head2 Revision

=over 4

=item *

$HeadURL: http://catwork.googlecode.com/svn/trunk/lib/catwork/Controller/Root.pm $

=item * 

$Id: Root.pm 2 2011-03-20 16:14:09Z hg.winkler.77 $

=back

=head2 Header Source Code

=cut

package catwork::Controller::Root;
use Moose;
use namespace::autoclean;

BEGIN { extends 'Catalyst::Controller' }

#
# Sets the actions in this controller to be registered with no prefix
# so they function identically to actions created in MyApp.pm
#
__PACKAGE__->config(namespace => '');

=head1 NAME

catwork::Controller::Root - Root Controller for catwork

=head1 DESCRIPTION

[enter your description here]

=head1 METHODS

=head2 index

The root page (/)

=head3 source code

=cut

sub index :Path :Args(0) {
    my ( $self, $c ) = @_;

    # Hello World
    $c->response->body( $c->welcome_message );
}

=head2 default

Standard 404 error page

=head3 source code

=cut

sub default :Path {
    my ( $self, $c ) = @_;
    $c->response->body( 'Page not found' );
    $c->response->status(404);
}

=head2 path_error

this function prints an pth error

=head3 url

/path_error/"error"

=head3 source code

=cut

sub path_error :Path :Args(1) {
    my ( $self, $c, $path_error ) = @_;
    $c->response->body("Something is wrong with \"$path_error\"");
    $c->response->status(404);
}

=head2 set_view

is a private function to set the output view

=head3 url

/set_view/*

suported are: json, default, mobile

=head3 stash

    $c->stash(current_view => "$view");

=head3 source code

=cut

sub set_view :Private {
    
    my ($self, $c, $view) = @_;
    
    if($view eq "default") {
        $c->stash(current_view => "Default");
    }
    elsif($view eq "mobile") {
        $c->stash(current_view => "Mobile");
    }
    elsif($view eq "json") {
        $c->stash(current_view => "JSON");
    }
    else {
        $c->forward("/path_error/$view");
    }
    
}

=head2 end

Attempt to render a view, if needed.

=head3 source code

=cut

sub end : ActionClass('RenderView') {}

=head1 AUTHOR

Hans-Georg Winkler,,,

=head1 LICENSE

This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

__PACKAGE__->meta->make_immutable;

1;
